package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.dto.CnyhrjzDto;
import com.ant.storage.pojo.Cnyhrjz;
import com.ant.storage.service.ICnyhrjzService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author melon
 * @since 2022-11-30
 */
@Api(tags = "银行日记账接口")
@RestController
@RequestMapping("/cnyhrjz")
public class CnyhrjzController {

    @Autowired
    private ICnyhrjzService cnyhrjzService;

    @ApiOperation(value = "获取列表")
    @GetMapping("/list")
    public ResultVo list(CnyhrjzDto dto) throws Exception{
        List<Cnyhrjz> list = cnyhrjzService.getList(dto);
        return ResultVo.success("操作成功",list);
    }

    @ApiOperation(value = "保存")
    @PostMapping("/saveCnxjrjz")
    public ResultVo saveCnxjrjz(@RequestBody Cnyhrjz cnyhrjz) throws Exception {
        cnyhrjzService.saveMsg(cnyhrjz);
        return ResultVo.success("操作成功");
    }

    @ApiOperation(value = "通过id获取详情")
    @GetMapping("/getById/{id}")
    public ResultVo getById(@PathVariable("id") Long id){
        Cnyhrjz detail = cnyhrjzService.getOne(new QueryWrapper<Cnyhrjz>().eq("FID",id));
        return ResultVo.success("操作成功",detail);
    }
}
